package com.xian.memory;

public class Test {
    public static void main(String[] args) {

        //目标：两个变量指向同一个对象
        Student s1 = new Student();
        System.out.println(s1);
        s1.name="小名";
        s1.sex='男';
        s1.hobby="学习，画画";

        s1.study();

        //把s1给s2----有一个垃圾回收（对象没有被用）
        Student s2 = s1;
        System.out.println(s2);
        System.out.println("--------------");
        s2.hobby="游泳";
        System.out.println(s2.name);
        System.out.println(s2.hobby);
        System.out.println(s1.hobby);
        System.out.println(s1.name);
        System.out.println("-------------");
        s1.study();
        s2.study();

    }
}
